package com.hcbd.tdwt.ui.xingyu.activity;
import android.annotation.SuppressLint;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.TextView;

import com.hcbd.tdwt.R;
import com.hcbd.tdwt.base.BaseActivity;
import com.raizlabs.android.dbflow.sql.language.SQLite;
import com.hcbd.tdwt.ui.xingyu.vo.BDBoxVO;
import com.hcbd.tdwt.ui.xingyu.vo.BDBoxVO_Table;
import org.androidannotations.annotations.AfterViews;
import org.androidannotations.annotations.Click;
import org.androidannotations.annotations.EActivity;
import org.androidannotations.annotations.ViewById;
@SuppressLint("NonConstantResourceId")
@EActivity(R.layout.activity_box_info)
public class BluetoothInfoActivity extends BaseActivity {
    @ViewById
    ImageButton headLeft;
    @ViewById(R.id.bluetooth_name)
    TextView bluetoothName;
    @ViewById(R.id.card_number_tv)
    TextView cardNumber;
    @ViewById(R.id.card_mode)
    TextView cardMode;
    @ViewById
    TextView adders;
    @ViewById
    Button delBtn;


    private BDBoxVO bdBoxVO;
    @AfterViews
    protected void init() {
        String adders=getIntent().getStringExtra("adders");
        bdBoxVO= SQLite.select().from(BDBoxVO.class).where(BDBoxVO_Table.macAdders.eq(adders)).querySingle();
        initData();
    }

    public void initData(){
        if(bdBoxVO!=null) {
            bluetoothName.setText(bdBoxVO.bluetoothName);
            cardNumber.setText(bdBoxVO.bdCardNum);
            cardMode.setText(bdBoxVO.cardMode);
            adders.setText(bdBoxVO.macAdders);
        }
    }
    @Click
    void delBtn(){
        showOldProtocolDialog("是否删除该蓝牙信息", (dialog, confirm) -> {
            if(confirm){
                bdBoxVO.delete();
                setResult(RESULT_OK);
                finish();
            }
            dialog.dismiss();
        });
    }
    @Click
    void headLeft(){
        finish();
    }
}
